package lab.domain;

import java.io.Serializable;
import java.util.HashMap;

/**
 *
 * @author Smike
 */
public class ChangableHashMap<K, V> extends HashMap<K, V> implements Serializable {

    private transient Record record;

    public Record getRecord() {
        return record;
    }

    public void setRecord(Record record) {
        this.record = record;
    }

    @Override
    public V put(K key, V value) {
        V v = super.put(key, value);
        notifyChanged();
        return v;
    }

    @Override
    public V remove(Object key) {
        V v = super.remove(key);
        notifyChanged();
        return v;
    }
    
    void notifyChanged() {
        if (record != null) {
            record.notifyChanged();
        }
    }
}
